import { gsap } from "gsap";

const ANIMATIONS_COMMON = {
    showAlert(app, message, type) {
        if (app.alertData.show) {
            return;
        }

        app.alertData = {
            show: true,
            message,
            type,
        };

        const showAlertTimeline = gsap.timeline({
            defaults: { duration: 0.5 },
            onComplete: () => {
                app.alertData = {
                    show: false,
                    message,
                    type,
                };
            },
        });

        showAlertTimeline
            .to(app, { alertOpacity: 1 })
            .to(app, { alertOpacity: 0 }, "+=1");
    },

    showAccountDropdown(app) {
        app.isAccountDropdownShow = true;
        gsap.to(app, {
            duration: 0.3,
            accountDropdownOpacity: 1
        });
    },

    hideAccountDropdown(app) {
        gsap.to(app, {
            duration: 0.3,
            accountDropdownOpacity: 0,
            onComplete() {
                app.isAccountDropdownShow = false;
            }
        });
    }
}



export default ANIMATIONS_COMMON;